import http from './http';
//获取验证码
export const getVerify = (captchaKey) => {
  localStorage.setItem("captchaKey", captchaKey);
  return http.requestGet('/user/captcha?captchaKey=' + captchaKey);
};
//解析token
export const checkToken = () => {
  return http.requestGet('/user/check-token');
};
//登录
export const doLogin = (captcha, captcha_key, sobUser) => {
  return http.requestPost('/user/login/' + captcha + '/' + captcha_key, sobUser);
};
//注册
export const register = (email_code, user) => {
  return http.requestPost('/user/register?email_code=' + email_code, user);
}
//退出登录
export const doLogout = () => {
  return http.requestGet('/user/logout');
};
//删除用户
export const deleteUserById = (userId) => {
  return http.requestDelete('/user/' + userId);
};
//修改密码
//重置密码
export const resetPassword = (userId, newPassword) => {
  return http.requestPut('/user/reset-password/' + userId + '?password=' + newPassword);
};
//获取邮箱验证码
export const getEmailVerify = (emailAddress) => {
  return http.requestGet('/user/verify_code?emailAddress=' + emailAddress);
};
//更新邮箱
export const updateEmailAddress = (emailAddress, verifyCode) => {
  return http.requestPut('/user/email?email=' + emailAddress + '&verify_code=' + verifyCode);
};
//检查用户名是否重复
export const checkUserName = (userName) => {
  return http.requestGet('/user/user_name?userName=' + userName);
};
//检查邮箱是否重复 
export const checkUserEmail = (emailAddress) => {
  return http.requestGet('/user/email?email=' + emailAddress);
};
//更新用户信息
export const updateUserInfo = (userInfo, userId) => {
  return http.requestPut('/user/' + userId, userInfo);
};
//获取分类列表
export const listCategories = (pageNo, pageSize) => {
  return http.requestGet('/admin/category/list?pageNo=' + pageNo + '&pageSize=' + pageSize);
};
//删除分类
export const deleteCategoryById = (categoryId) => {
  return http.requestDelete('/admin/category/' + categoryId);
};
//添加分类
export const postCategory = (category) => {
  return http.requestPost('/admin/category/', category);
};
//更新分类
export const updateCategory = (categoryId, category) => {
  return http.requestPut('/admin/category/' + categoryId, category);
};
//获取轮播图列表
export const listLoop = () => {
  return http.requestGet('/admin/looper/list');
};
//添加轮播图
export const postLoop = (looper) => {
  return http.requestPost('/admin/looper', looper);
};
//更新轮播图
export const updateLoop = (looperId, loop) => {
  return http.requestPut('/admin/looper/' + looperId, loop);
};
//删除轮播图
export const deleteLoop = (looperId) => {
  return http.requestDelete('/admin/looper/' + looperId);
};
//获取用户列表
export const listUsers = (pageNo, pageSize, username, email) => {
  return http.requestGet('/user/page?pageNo=' + pageNo + '&pageSize=' + pageSize + '&username=' + username + '&email=' + email);
};


//获取网站信息
export const getSeoInfo = () => {
  return http.requestGet('/admin/web_size_info/seo');
};
//获取网站标题
export const getWebSizeTitle = () => {
  return http.requestGet('/admin/web_size_info/title');
};
//更新网站标题
export const updateWebSizeTitle = (title) => {
  return http.requestPut('/admin/web_size_info/title?title=' + title);
};
//更新网站信息
export const updateWebSizeSeo = (description, keywords) => {
  return http.requestPut('/admin/web_size_info/seo?description=' + description + '&keywords=' + keywords);
};
//获取友情链接列表
export const listFriendLinks = (pageNo, pageSize) => {
  return http.requestGet('/admin/friend/list?pageNo=' + pageNo + '&pageSize=' + pageSize);
};
//添加友情链接列表
export const postFriendLink = (FriendsLink) => {
  return http.requestPost('/admin/friend', FriendsLink);
};
//更新友情链接列表
export const updateFriendLink = (friendLinkId, FriendsLink) => {
  return http.requestPut('/admin/friend/' + friendLinkId, FriendsLink);
};
//删除友情链接
export const deleteFriendLink = (linkId) => {
  return http.requestDelete('/admin/friend/' + linkId);
};

//获取图片列表
export const listImages = (pageNo, pageSize, original) => {
  return http.requestGet('/admin/images/list?pageNo=' + pageNo + '&pageSize=' + pageSize + '&original=' + original);
};


//发表文章
export const postArticle = (article) => {
  return http.requestPost('/admin/article', article);
};

//草稿发布
export const publicDraftArticle = (articleId) => {
  return http.requestPut('/admin/article/publish/' + articleId);
}

//保存草稿
export const saveArticleDraft = (article) => {
  return http.requestPost('/admin/article', article);
};
//置顶文章
export const topArticle = (articleId) => {
  return http.requestPut('/admin/article/top/' + articleId);
};

//逻辑删除
export const deleteArticlePretend = (articleId) => {
  return http.requestDelete('/admin/article/' + articleId);
};
//绝对删除
export const deleteArticleAbs = (articleId) => {
  return http.requestDelete('/admin/article/' + articleId);
};

//获取文章列表
export const listArticles = (pageNo, pageSize, state, keyword, categoryId) => {
  return http.requestGet('/admin/article/list?pageNo=' + pageNo + '&pageSize=' + pageSize + '&state='
    + state + '&categoryId=' + categoryId + '&keyword=' + keyword);
};
//获取文章详情
export const getArticleDetail = (articleId) => {
  return http.requestGet('/admin/article/' + articleId);
};

//更新文章
export const updateArticle = (articleId, article) => {
  return http.requestPut('/admin/article/' + articleId, article);
};
//获取评论列表
export const listComments = (pageNo, pageSize) => {
  return http.requestGet('/admin/comment/list?pageNo=' + pageNo + '&pageSize=' + pageSize);
};
//删除评论
export const deleteCommentById = (commentId) => {
  return http.requestDelete('/admin/comment/' + commentId);
};
//置顶评论
export const topComment = (commentId) => {
  return http.requestPut('/admin/comment/top/' + commentId);
};
//删除图片
export const deleteImageById = (imageId) => {
  return http.requestDelete('/admin/images/' + imageId);
};
//获取文章数量
export const getArticleCount = () => {
  return http.requestGet('/admin/article/count');
};
//获取用户数量
export const getUserCount = () => {
  return http.requestGet('/user/register_count');
};
//获取评论数量
export const getCommentCount = () => {
  return http.requestGet('/admin/comment/count');
};
//获取网站浏览量
export const getViewCount = () => {
  return http.requestGet('/admin/web_size_info/view_count');
};
//上传图片
export const imgUpload = (file, original) => {
  return http.requestUpload('/admin/images/upload?original=' + original, file)
}
//获取网站列表
export const websiteList = (pageNo, pageSize, categoryId, title) => {
  return http.requestGet('/admin/website/list?pageNo=' + pageNo + '&pageSize=' + pageSize + '&categoryId=' + categoryId + '&title=' + title)
}
//添加网站
export const addWebSite = (websiteCollect) => {
  return http.requestPost('/admin/website', websiteCollect)
}
//修改网站
export const updateWebSite = (websiteId, websiteCollect) => {
  return http.requestPut('/admin/website/' + websiteId, websiteCollect)
}
//删除网站
export const deleteWebSite = (websiteId) => {
  return http.requestDelete('/admin/website/' + websiteId)
}
//获取网站分类
export const websiteCategoryList = (pageNo, pageSize) => {
  return http.requestGet('/admin/website/category/list?pageNo=' + pageNo + '&pageSize=' + pageSize)
}
//添加网站分类
export const addWebsiteCategory = (websiteCategory) => {
  return http.requestPost('/admin/website/category', websiteCategory)
}
//编辑网站分类
export const updatedWebsiteCategory = (categoryId, websiteCategory) => {
  return http.requestPut('/admin/website/category/' + categoryId, websiteCategory)
}
//删除网站分类
export const deleteWebsiteCategory = (categoryId) => {
  return http.requestDelete('/admin/website/category/' + categoryId);
}
/**系统 */
//操作日志列表
export const sysOperationLogS = (pageNo, pageSize, keyword) => {
  return http.requestGet('/admin/system/list?pageNo=' + pageNo + '&pageSize=' + pageSize + '&keyword=' + keyword)
}
